/*************************************************************************
    > File Name: test.c
    > Author: ma6174
    > Mail: ma6174@163.com 
    > Created Time: Tue 04 Mar 2025 10:19:12 PM CST
 ************************************************************************/

#include<stdio.h>
#include<string.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>


int main()
{
	umask(0);
	int fd = open("log.txt",O_WRONLY | O_CREAT | O_TRUNC,0666);
	//写的方式打开文件，没有则新建，权限设置为-rw-rw-rw-
	if(fd<0)
	{
		perror("open failed!");                   //打开失败，显示错误
		return 1;
	}

	const char* message = "xxxxxx!\n"; 
	write(fd,message,strlen(message));            //

	close(fd);                                    //关闭文件
	return 0;
}
